#
#   index.py
#   DrAnn
#
#   Created by luoxh on 2019-07-15-10:51.
#   Copyright © 2019 luoxh. All rights reserved.
#
import os
from datetime import timedelta


class BaseConfig:
    """
    基本配置
    """
    # flask配置
    APP_NAME = 'journalismManger'
    SECRET_KEY = 'tgE0TP71Msvf37TYORWfOietrBgfoPPnUf7DEWHxFjozTicLWqWbp7ntSUHiITFY'

    # SERVER_NAME = '192.168.0.130:5566'

    # 路径配置
    BASE_DIRS = os.getcwd()
    PUBLIC_DIRS = BASE_DIRS + '/public'
    TEMPLATE_DIRS = PUBLIC_DIRS + '/templates'
    STATIC_DIRS = PUBLIC_DIRS + '/static'

    # 打包路径
    DIST_DIRS = BASE_DIRS + '/dist'
    DIST_PUBLIC_DIRS = DIST_DIRS + '/public'
    BUILD_DIRS = BASE_DIRS + '/build'

    # session
    PERMANENT_SESSION_LIFETIME = timedelta(days=1.0)
    SESSION_TYPE = 'mongodb'
    SESSION_COOKIE_NAME = f'{APP_NAME}_ID'
    SESSION_COOKIE_SECURE = False
    SESSION_MONGODB_DB = 'journalismManger'
    SESSION_MONGODB_COLLECT = 'session'

    # 白名单urls
    white_list = ['/accounts/avatar', '/accounts/_avatar', '/accounts/not_logined', '/accounts/logout',
                  '/accounts/pic_captcha', '/user/login', '/other/landing_page', '/other/upload_img',
                  '/other/tmp_proxy', '/other/get_test_comic_images', '/user/change_avatar', ]
    # 每个版本，每个平台都不一样，发给客户端，用于api加密传输数据
    API_SECRET_KEYS = {"ios": {'1.0.8': "bW0OgOtYaoMum0HhRXlMXb1XbRK21fSSBAwPYQXc177p6fyouOEpxB4D57X997Vk"}, "ios_other": {'1.0.8': "8DEbXKl15qgxaKzH46lr9UAx1wqYXilPG4DuPxcs5Sx3xmDtCJHM1aGMryTCvBPs"}, 'android': {'1.0.8': "IZYdgssrcZThSOT5FCXeZxIz9Sth9slRQHJGhPs5LIgUfUXXZqxTABLAfqrJPyWe"}}
    # JWT
    JWT_AUTH_URL_RULE = '/login'
    JWT_EXPIRATION_DELTA = timedelta(days=1.0)
    JWT_AUTH_USERNAME_KEY = 'username'
    JWT_AUTH_PASSWORD_KEY = 'password'

    MONGODB_SETTINGS = {'db': 'journalismManger', 'host': 'mongodb://localhost/journalismManger', 'connect': False, }


class DevConfig(BaseConfig):
    """
    开发环境配置
    """
    DEBUG = True
    TEMPLATES_AUTO_RELOAD = True


class ProdConfig(BaseConfig):
    """
    生产环境配置
    """
